﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;

namespace Validate_Solution
{
    public class ErrorManager
    {
        Color errorColor = Color.Red;
        Hashtable oldColors;

        public ErrorManager()
        {
            oldColors = new Hashtable();
        }

        public Color ErrorColor
        {
            get { return errorColor; }
            set { errorColor = value; }
        }

        public void SetError(Control control)
        {
            ClearError();
            oldColors.Add(control, control.BackColor);
            control.BackColor = errorColor;
        }

        public void SetErrors(Control[] controls)
        {
            ClearError();
            foreach (Control control in controls)
            {
                oldColors.Add(control, control.BackColor);
                control.BackColor = errorColor;
            }
        }

        public void ClearError()
        {
            foreach (Control control in oldColors.Keys)
            {
                control.BackColor = (Color)oldColors[control];
            }
            oldColors.Clear();
        }
    }
}
